using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TablePatrolDao:DaoBase<TablePatrol>
    {
        public override void AddPrimaryIndex(TablePatrol model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TablePatrol.txt";
        }

        protected override TablePatrol ParseRowData(string[] rowData)
        {
            TablePatrol data = new TablePatrol();
			data.id = rowData [0];
			data.npcId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.x = 0;
            }
            else
            {
                data.x = double.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.y = 0;
            }
            else
            {
                data.y = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.z = 0;
            }
            else
            {
                data.z = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.time = 0;
            }
            else
            {
                data.time = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.offsetTime = 0;
            }
            else
            {
                data.offsetTime = double.Parse(rowData[6]);
            }

            return data;
        }


        public override void AddOneIndex(TablePatrol model)
        {
            if (!cacheOneIndex.ContainsKey(model.npcId.ToString()))
            {
                cacheOneIndex[model.npcId.ToString()] = new List<TablePatrol>();
            }
            cacheOneIndex[model.npcId.ToString()].Add(model);
        }
    

    }

}
